import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;


public class SimpleClient {
	public static void main(String[] args) throws IOException {

		if (args.length != 1) {
			System.out.println("Usage: java SimpleClient <hostname>");
			return;
			
		}
		
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String lineToSend = stdIn.readLine();
	
		// Open a datagram socket
		DatagramSocket socket = new DatagramSocket();
	
		// Send packet
		// Check buf is not larger than 256
		byte[] buf = lineToSend.getBytes("8859_1" /* encoding */);	// "8859_1" encoding simply chops the high byte off or pads the high byte with 0s, what newbies erroneously imagine happens all the time.
		InetAddress address = InetAddress.getByName(args[0]);
		System.out.println(InetAddress.getLocalHost().getHostName());
		DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 4444);
		System.out.println(socket.getLocalAddress().getHostName());
		socket.send(packet);
		
        socket.close();
    }
}